import tab from './tab'
import auth from './auth'
import cache from './cache'
import modal from './modal'
import {enumStatus} from './enum'
import {orderStatus} from './order'
import config from '@/config'
import {isWebView, isWechat} from "../utils/validate";
import signTaskDialog from "./signTaskDialog";

export default {
    install(Vue) {
        // 页签操作
        Vue.prototype.$tab = tab
        // 认证对象
        Vue.prototype.$auth = auth
        // 缓存对象
        Vue.prototype.$cache = cache
        // 模态框对象
        Vue.prototype.$modal = modal
        // 枚举对象
        Vue.prototype.$enums = enumStatus
        // 订单状态
        Vue.prototype.$order = orderStatus
        // 签署任务 和 实名认证 任务提示框
        Vue.prototype.$signTaskDialog = signTaskDialog
        // 短信验证码倒计时
        Vue.prototype.$smsCounter = 80
        // 订单状态
        Vue.prototype.$ossUrl = 'https://cs.lksign.cn:8197/dev-api'
        // 唤起微信客服链接
        Vue.prototype.$wechatUrl = 'https://work.weixin.qq.com/kfid/kfccfff96f59c11e403'
        // 余额充值 统一跳转
        Vue.prototype.$goPay = () => {
            if (navigator.vibrate) {
                navigator.vibrate(50);
            }
            if (isWebView()) {
                // TODO 小程序支付
            } else if (isWechat()) {
                // jsapi支付 跳转到授权code
                window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx03b2c7ac53dab678' +
                    '&redirect_uri=' + config.h5Url + '/pages/mine/signFlowFeeOrder/recharge/index' +
                    '&response_type=code' +
                    '&scope=snsapi_base#wechat_redirect'
                return;
            } else {
                // h5 直接跳转
                tab.navigateTo('/pages/mine/signFlowFeeOrder/recharge/index')
            }
        }
    }
}
